Skip to content

fix: error version judgement#349

Merged
max-lvs merged 1 commit into
linuxdeepin:release/eaglefrom
LiHua000:release/eagle
Aug 9, 2025
Merged

fix: error version judgement#349
max-lvs merged 1 commit into
linuxdeepin:release/eaglefrom
LiHua000:release/eagle

Conversation

@LiHua000
Copy link
Copy Markdown
Contributor

Correct the misnamed macro definition introduced in the previous compilation error fix

Log: fix build error

Correct the misnamed macro definition introduced in the previous compilation error fix

Log: fix build error
@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

代码审查意见:

  1. 代码重复

    • slotUninstallPackageinstallDebs函数中,获取当前真实用户信息的代码块是相同的,应该提取成一个单独的函数来避免重复代码。
  2. 宏定义错误

    • slotUninstallPackage函数中,宏定义DENABLE_VIRTUAL_PACKAGE_ENHANCE应该是ENABLE_VIRTUAL_PACKAGE_ENHANCE,否则条件编译将不会生效。
  3. 内存管理

    • slotUninstallPackage函数中,transsaction指针被保存到m_currentTransaction成员变量中,但没有看到相应的内存释放或指针置空操作,可能会导致内存泄漏。
  4. 代码可读性

    • slotUninstallPackage函数中,connect语句和deleteLater调用之间没有注释说明其目的,建议添加注释以提高代码可读性。
  5. 变量命名

    • transsaction变量名拼写错误,应该是transaction
  6. 宏定义检查

    • installDebs函数中,宏定义DENABLE_VIRTUAL_PACKAGE_ENHANCE应该是ENABLE_VIRTUAL_PACKAGE_ENHANCE,否则条件编译将不会生效。
  7. 环境变量检查

    • 在获取环境变量SUDO_USER时,应该检查该变量是否存在,以避免潜在的空指针访问。
  8. 代码风格

    • installDebs函数中,QProcessEnvironment env = QProcessEnvironment::systemEnvironment();QVariantMap map;之间的空行可以去掉,以保持代码紧凑。

综合以上意见,建议进行如下修改:

void DebListModel::slotUninstallPackage(const int index)
{
    // 卸载结束之后 删除指针
    connect(transsaction, &Transaction::finished, transsaction, &Transaction::deleteLater);

    m_currentTransaction = transsaction;   //保存trans指针
    // 获取当前真实用户信息
    if (ENABLE_VIRTUAL_PACKAGE_ENHANCE) {
        QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
        QString currentUser = env.value("USER");
        QString realUser = env.value("SUDO_USER").toString();
        // 如果SUDO_USER存在,说明当前是通过sudo启动的
        if (!realUser.isEmpty()) {
            currentUser = realUser;
        }
        // 其他处理...
    }
}

void DebListModel::installDebs()
{
    m_currentTransaction = transaction;

    if (ENABLE_VIRTUAL_PACKAGE_ENHANCE) {
        QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
        QString currentUser = env.value("USER");
        QString realUser = env.value("SUDO_USER").toString();
        // 如果SUDO_USER存在,说明当前是通过sudo启动的
        if (!realUser.isEmpty()) {
            currentUser = realUser;
        }
        // 其他处理...
    }
}

以上修改建议旨在提高代码质量、可读性和安全性。

@LiHua000
Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
Copy link
Copy Markdown
Contributor

deepin-bot Bot commented Jul 28, 2025

This pr cannot be merged! (status: unstable)

@LiHua000
Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
Copy link
Copy Markdown
Contributor

deepin-bot Bot commented Jul 28, 2025

This pr cannot be merged! (status: unstable)

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LiHua000, max-lvs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@max-lvs max-lvs merged commit c92ee3b into linuxdeepin:release/eagle Aug 9, 2025
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants